<template>
<div>
 <el-table
    :data="tableData"
    border
    style="width: 100%">
    <el-table-column
      prop="id"
      label="工号"
      width="300">
    </el-table-column>
    <el-table-column
      prop="teachername"
      label="教师姓名"
      width="200">
    </el-table-column>
    <el-table-column
      prop="teacherclass"
      label="教授班级"
      width="200">
    </el-table-column>
    <el-table-column
      fixed="right"
      label="操作">
        <el-button @click="backCourse()" type="primary" size="small" icon="el-icon-edit">返回课程页面</el-button>
    </el-table-column>
  </el-table>
<!--修改用户 -->
</div>
</template>

<script>
import axios from 'axios'
export default {
  methods: {
    deleteid (row) {
      axios.delete(`http://localhost:8082/StudentManagement-Web/teacher/delete/${row.id}.json`).then(function (resp) { alert('删除成功') })
    },
    edid (row) {
      this.$router.push({
        path: '/Updata',
        query: {
          id: row.id
        }
      })
    },
    page (currentPage) {
      const _this = this
      axios.get(`http://localhost:8082/StudentManagement-Web/teacher/findall/${currentPage}/2.json`).then(function (resp) { _this.tableData = resp.data.content; _this.total = resp.data.totalElements })
    },
    back () {
      this.$router.replace('/Home')
    },
    show (row) {
      console.log(row)
      const _this = this
      axios.get('http://localhost:localhost:8082/StudentManagement-Web/teacher/17.json').then(function (resp) { _this.tableData = resp.data })
      this.edidialogVisible = true
    },
    showid (id) {
      console.log(id)
      const _this = this
      this.edidialogVisible = true
      axios.get(`http://localhost:8082/StudentManagement-Web/teacher/findbyid/${id}.json`, this.edidFrom).then(function (res) { _this.edidFrom = res.data; console.log(_this.edidFrom.name) })
    },
    updata () {
      this.$refs.edidFromRef.validate((valid) => {
        if (valid) {
          axios.put('http://localhost:8082/StudentManagement-Web/teacher/updata.json', this.edidFrom).then(function (resp) { alert('success') })
        } else {
          console.log('失败!!')
          return false
        }
      })
    },
    find (id) {
      console.log(id)
      const _this = this
      this.asd = true
      axios.get(`http://localhost:8082/StudentManagement-Web/teacher/findbyid/${id}.json`, this.form).then(function (res) { _this.form = res.data })
    },
    backCourse () {
      this.$router.replace('/Course')
    }
  },
  created () {
    const _this = this
    axios.get('http://localhost:8082/StudentManagement-Web/teacher/findall/1/2.json').then(function (resp) { _this.tableData = resp.data.content; _this.total = resp.data.totalElements })
  },
  data () {
    return {
      total: null,
      tableData: null,
      edidialogVisible: false,
      edidFrom: {},
      pagesize: 2,
      form: {},
      asd: false,
      loading: false
    }
  }
}
</script>
